<?php
namespace app\admin\controller;
use think\Controller;
use think\Session;

class Common extends Controller
{
    private $session_prefix = "admin";
    public function _initialize()
    {
        //设置当前session的作用域
        Session::prefix($this->session_prefix);
        //检查登录状态
        if(!$this->isLogin())
        {
            $this->redirect(url('Login/index'));
        }
    }

    public function isLogin()
    {
        return !empty(session('adminId'));
    }

    /**加密一个客户端id
     * @param $client_id
     * @return string
     */
    protected function EncUserid($client_id)
    {
        return sha1($client_id);
    }
}